package com.csjbot.snowbot_rogue.camera.mode;

import android.content.Context;
import android.graphics.Bitmap;
import android.media.FaceDetector;
import android.os.Handler;
import android.os.Message;

import com.csjbot.snowbot_rogue.camera.listener.CsjFaceDetectorListener;
import com.csjbot.snowbot_rogue.camera.util.EventUtil;

/**
 * Copyright (c) 2017, SuZhou CsjBot. All Rights Reserved.
 * www.csjbot.com
 * <p>
 * Created by 浦耀宗 at 2017/1/9-21:58.
 * Email: puyz@csjbot.com
 */
public class CsjFaceDetect implements CsjFaceDetectorListener {
    private static final String TAG = "YanZi";
    private Context mContext;
    private Handler mHander;

    public CsjFaceDetect(Context c, Handler handler) {
        mContext = c;
        mHander = handler;
    }

    @Override
    public void onFaceDetected(FaceDetector.Face[] faces, int faceCount, Bitmap oriBitmap) {
        if (faces != null) {

            Message m = mHander.obtainMessage();
            m.what = EventUtil.UPDATE_FACE_RECT;
            m.arg1 = faceCount;
            m.obj = faces;
            m.sendToTarget();
        }
    }
}
